package com.shitu.soulemo.a;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.shitu.base.BaseFragment;
import com.shitu.soulemo.R;

/**
 * Created by majie on 2018/3/18.
 */

public class AFragment extends BaseFragment {
    private ViewPager pager;
    private TabLayout tabs;
    private FenleiFragment flFragment;
    private TuijianFragment tjFragment;
    private WupinFragment wpFragment;
    private FuwuFragment fwFragment;
    private XinxinFragment xxFragment;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.a_fragment, null);

        pager = view.findViewById(R.id.viewpager);
        tabs = view.findViewById(R.id.tablayout);

        initViews();
        return view;
    }

    private void initViews() {
        AAdapter adapter = new AAdapter(getChildFragmentManager());
        flFragment = new FenleiFragment();
        tjFragment = new TuijianFragment();
        fwFragment = new FuwuFragment();
        wpFragment = new WupinFragment();
        xxFragment = new XinxinFragment();
     //   adapter.addData(flFragment);//暂时隐藏分类按钮
        adapter.addData(tjFragment);
        adapter.addData(fwFragment);
        adapter.addData(wpFragment);
        adapter.addData(xxFragment);
        pager.setAdapter(adapter);

        tabs.setupWithViewPager(pager);
    }
}
